from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.executors.pool import ThreadPoolExecutor
import time

# 1.定义执行器
executors = {
    'default': ThreadPoolExecutor(max_workers=10)
}
# 2.创建调度器
scheduler = BackgroundScheduler(executors=executors)

# 3.定义定时任务函数
def print_tset():
    print(111)

# 4.添加定时任务
scheduler.add_job(print_tset, 'interval', seconds=3)

# 5.启动调度器,不阻塞
scheduler.start()

# 6.手动添加代码,防止程序退出
while 1:
    time.sleep(3*60)
